#pragma once

#include <arpa/inet.h>
#include <fcntl.h>
#include <stdint.h>
#include <strings.h>
#include <sys/socket.h>
#include <unistd.h>
#include <string>

/// 半关闭？？？
class InetAddress;

class Socket {
public:
    Socket(int sockfd);

    void Create();

    void Bind(InetAddress address);

    void Listen(int logback = 10);

    int Accept(InetAddress* address);

    // 设置套接字为非阻塞
    bool SetNonBlock();

    void Shutdown();

    // 支持端口复用
    void SetReuseAddress(bool on);
    void SetReusePort(bool on);

    int Fd();

    ~Socket();

private:
    int sockfd_;
};